// pages/loupan/comment/list.js
var app =getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
		id: '',
		detail: '',
		moretext: "点击查看更多",
		showmore: false,
		liked: false,
		imglist: '',
		wuyetype: '', // 物业类型
		wenda: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		this.setData({
			id:options.id
		})
		this.detail()
  },

	detail() {
		var id = this.data.id;
		var that = this;
		var opid = wx.getStorageSync('user').openid;
		app.core('get', 'get_houses_detail/id/' + id + '/open_id/' + opid + '', {}
			, (res) => {
				console.log(res)

				var newres = res.data;
				var wuyetype = res.data.propertyType;
				switch (wuyetype) {
					case "-1-3-":
						wuyetype = "-住宅-写字楼-"
						break;
					case "-1-2-":
						wuyetype = "-住宅-商铺-"
						break;
					case "-1-2-3":
						wuyetype = "-住宅-商铺-写字楼-"
						break;
					case "-2-3-":
						wuyetype = "-商铺-写字楼-"
						break;
				}


				var arr = [];
				if (res.data.buildNoPhoto) {
					arr.push(res.data.buildNoPhoto);
				}
				if (res.data.effectPhoto) {
					arr.push(res.data.effectPhoto);
				}
				if (res.data.trafficPhoto) {
					arr.push(res.data.trafficPhoto);
				}
				if (res.data.dimensionPhoto) {
					arr.push(res.data.dimensionPhoto);
				}
				if (res.data.videoPhoto) {
					arr.push(res.data.videoPhoto);
				}
				that.setData({
					wuyetype: wuyetype,
					detail: res.data,
					liked: res.hasCollect
				})
				that.setData({
					imglist: arr
				})
				var x = res.data.loupan_wenda;
				var wenda = [];
				for (var i = 0; i < x.length; i++) {
					if (x[i].p_wenda_id == 0) {
						wenda.push(x[i])
					}
				}
				that.setData({
					wenda: wenda
				})
				console.log(wenda,1223)
			}
		)
	},// 获取详情
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})